package com.job.liushuang.HomeWork0716;

/**
 * @author Liushuang
 * @version 1.0
 * @since 2022-07-16 19:13:36
 */
public class StringBuffer02 {
    public static void main(String[] args) {
        String url="http://localhost:8080/admin/table/tablelist.html";
        StringBuffer sbf=new StringBuffer(url);
        String find="8080",port="9000";
        int index=sbf.indexOf(find);
        //开始下标包括，结束下标不包括
        sbf.replace(index, index+find.length(), port);
        url=sbf.toString();
        System.out.println(url); //http://localhost:9000/admin/table/tablelist.html

        int lastIndex=sbf.lastIndexOf("table");
        sbf.delete(lastIndex, lastIndex+5);
        url=sbf.toString();
        System.out.println(url);  //http://localhost:9000/admin/table/list.html

        sbf.insert(4,'s');
        url=sbf.toString();
        System.out.println(url);  //http://localhost:9000/admin/table/list.html

        String src="2442";
        StringBuffer sbf2=new StringBuffer(src);
        String dest=sbf2.reverse().toString();

        if (src.equals(dest)){
            System.out.println("回文");
        }
    }
}
